using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wumpus
{
    public class Connections : IEnumerable<List<int>>
    {
        public Connections(List<List<int>> connections) { this.cons = connections; }

        public bool AreConnected(int Planet1, int Planet2)
        {
            for (int i = 0; i < cons[Planet1].Count; i++)
                if (cons[Planet1][i] == Planet2) return true;

            return false;
        }

        public List<int> this[int index] { get { return cons[index]; } }

        internal readonly List<List<int>> cons; //internal so it can be read by serializer

        //IEnumerable stuff.
        private int position = -1;

        //both of the following functions required to satisfy the IEnumerable Gods
        public IEnumerator<List<int>> GetEnumerator()
        {
            return cons.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

    }
}
